class TreeNode {
    int val;
    TreeNode left;
    TreeNode right;
    TreeNode() {}
    TreeNode(int val) { this.val = val; }
    TreeNode(int val, TreeNode left, TreeNode right) {
        this.val = val;
        this.left = left;
        this.right = right;
    }
}

public class Solution {
    public TreeNode find(TreeNode root, int val){
        if(root == null){
            return null;
        }
        if(root.val == val){
            return root;
        }
        //先去左边找
        TreeNode ret = find(root.left,val);
        if(ret != null){
            return ret;
        }

        //再去右边找
        ret = find(root.right,val);
        if(ret != null){
            return ret;
        }
        return null;
    }
}
